//在数组中查找一个元素

public class Main {
    public static int getElment(int[] array,int index){
        if(array == null){
            // 数组为空, 抛出空指针异常
            throw new NullPointerException("传递的数组为null");
        }
        if(index<0 || index>= array.length){
            // 数组下标越界, 抛出另一个异常
            throw new ArrayIndexOutOfBoundsException("数组越界异常");
        }
        return array[index];
    }

    public static void main(String[] args) {
        int[] arrs = {1,2,3};
        getElment(arrs,3);
    }
}
